$(function () {
   obj.init();
});
var obj = new function () {
    'use strict';
    return {
        form:null,
        table:null,
        room:null,
        currentId:null,
        init:function () {
            this.room = xhTool.getQuery('room');
            this.currentId = xhTool.getQuery('currentId');
            this.table = $('#dataTable');
            this.funObj().loadData();
            this.listener();
        },
        listener:function () {
            var $this = this;
            
            $('#btn_view').click(function () {
                $this.funObj().loadData();
            })
        },
        funObj:function () {
            var $this = this;
            return {
                loadData:function () {
                    var params = {
                        startTime: $('#startTime').val(),
                        endTime  : $('#endTime').val(),
                        room     : $this.room,
                        currentId: $this.currentId
                    };
                    xhExtra.ajaxRequest('lm/meeting/getMeetingByTime',params,{},function (res) {
                        var str = '<tbody>';
                        if (res.length > 0) {
                            $.each(res, function (i,item) {
                                str +=
                                    '               <tr class="'+item['className']+'" >\n' +
                                    '                    <td style="width: 20%">'+item['sApplyName']+'</td>\n' +
                                    '                    <td style="width: 20%">'+item['sDepName']+'</td>\n' +
                                    '                    <td style="width: 30%">'+item['tStartTime']+'</td>\n' +
                                    '                    <td style="width: 30%">'+item['tEndTime']+'</td>\n' +
                                    '                </tr>';
                            });
                        } else {
                            str +=
                                '               <tr>\n' +
                                '                    <td colspan="4">暂无数据</td>\n' +
                                '                </tr>';
                        }
                        str += '</tbody>';
                        $this.table.empty().append(str);
                    })
                }
            }
        }
    }
};